package com.ysc.chessfightbackend.util;

/**
 * Version: 1.0
 * Class Name: UserContextHolder
 * Description: 存储当前线程中的用户Id
 * Author: ysc
 * Date: 2024/5/15 10:20
 */
public class UserContextHolder {
    private static final ThreadLocal<Long> userHolder = new ThreadLocal<>();

    public static void set(Long userId) {
        userHolder.set(userId);
    }

    public static Long get() {
        return userHolder.get();
    }

    public static void clear() {
        userHolder.remove();
    }
}
